package slimeVolleyball;

import javax.swing.*;
import java.awt.*;
import java.util.*;

public class SlimeGui extends JComponent
{
	Slime slimeOne;
	Slime slimeTwo;
	SlimeListener listener;
	Net net;
	Ball ball;
	
	public SlimeGui()
	{
		super();
		slimeOne = new Slime(100, 430,100, 70, 180, -180, 1, this, 1, false, false, net);
		slimeTwo = new Slime(550, 430,100, 70, 180, -180, 2, this, 1, false, false, net);
		listener = new SlimeListener(this, slimeOne, slimeTwo);
		net = new Net(125, this, 395);
		ball = new Ball(390, 230, 20, 20, this, slimeOne, slimeTwo);
		setFocusable(true);
        setBounds(0, 0, 800, 500);
	}
	
	public void paintComponent(Graphics g)
	{	
		super.paintComponent(g);
        if(slimeOne.slimeColor() <2)
        {
                g.setColor(Color.WHITE);
        }
        else if(slimeOne.slimeColor() ==2)
        {
                g.setColor(Color.ORANGE);
        }
        else if(slimeOne.slimeColor() ==3)
        {
                g.setColor(Color.CYAN);
        }
        else if(slimeOne.slimeColor() ==4)
        {
                g.setColor(Color.GREEN);
        }
        g.fillArc(slimeOne.slimeCoordX(), slimeOne.slimeCoordY(), slimeOne.slimeWidth(), slimeOne.slimeHeight(), 180, -180);
        
        
        if(slimeTwo.slimeColor() ==1)
        {
                g.setColor(Color.WHITE);
        }
        else if(slimeTwo.slimeColor() ==2)
        {
                g.setColor(Color.ORANGE);
        }
        else if(slimeTwo.slimeColor() ==3)
        {
                g.setColor(Color.CYAN);
        }
        else if(slimeTwo.slimeColor() ==4)
        {
                g.setColor(Color.GREEN);
        }
        else if(slimeTwo.slimeColor()>4)
        {
                slimeTwo.resetColor();
        }
        g.fillArc(slimeTwo.slimeCoordX(), slimeTwo.slimeCoordY(), slimeTwo.slimeWidth(), slimeTwo.slimeHeight(), 180, -180);
        
        g.setColor(Color.WHITE);
        g.fillRect(net.getX(), 500-net.getHeight(), 10, net.getHeight());
        g.fillOval(ball.getX(), ball.getY(), 20, 20);
	}
	public void update()
	{
		repaint();
	}
}
